
package GUI;

/**
 *
 * @author Isaac
 */
import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableModel;

public class JanelaGerenciarConsorcio extends javax.swing.JFrame {

    ControladorGerenciarConsorcio cGCO;
    ControladorJanelaPrincipal cJP;

    public void setControladorJanelaPrincipal(ControladorJanelaPrincipal cJP){
        this.cJP = cJP;
    }

    /** Creates new form JanelaGerenciarConsorcio */
    public JanelaGerenciarConsorcio() {
        initComponents();
        setLocationRelativeTo(null);
        buttonGroupPesquisa.clearSelection();
    }

    //A classe principal conhece a JanelaGerenciarConsorcio
    public void setControladorGerenciarConsorcio (ControladorGerenciarConsorcio c){
        cGCO = c;
        botaoExcluirConsorcio.addActionListener(cGCO);
        botaoCadastrarConsorcio.addActionListener(cGCO);
        botaoPesquisa.addActionListener(cGCO);
        botaoGerarGrafico.addActionListener(cGCO);
        botaoSair.addActionListener(cGCO);
        botaoRelatorio.addActionListener(cGCO);
        jTable2.addMouseListener(c);
        jTable2.setModel(new ModeloTabelaConsorcio());
        }

    public JTable getjTable2() {
        return jTable2;
    }

    public void setJTable (ModelTable mt)
    {
        try
        {
            jTable2.setModel((TableModel)mt);
        }catch (NullPointerException e)
        {
            e.getStackTrace();
        }
    }

    public String getCampoPesquisa() {
        return campoPesquisa.getText();
    }

    public void setCampoPesquisa(String campoPesquisa) {
        this.campoPesquisa.setText(campoPesquisa);
    }

    public String getBotaoSelecionado() {
        if (radioData.isSelected())
        {
            return radioData.getText();
        }else if(radioModelo.isSelected())

        {
            return radioModelo.getText();
        }else if (radioPlano.isSelected())
        {
            return radioPlano.getText();
        }

        return "Selecione a opção de pesquisa";
    }

    public ButtonGroup getButtonGroupPesquisa() {
        return buttonGroupPesquisa;
    }



    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupPesquisa = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        botaoCadastrarConsorcio = new javax.swing.JButton();
        botaoGerarGrafico = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        radioPlano = new javax.swing.JRadioButton();
        radioModelo = new javax.swing.JRadioButton();
        radioData = new javax.swing.JRadioButton();
        campoPesquisa = new javax.swing.JTextField();
        botaoPesquisa = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        botaoExcluirConsorcio = new javax.swing.JButton();
        botaoSair = new javax.swing.JButton();
        botaoRelatorio = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Gerenciar Consórcio");

        jPanel1.setBackground(new java.awt.Color(204, 204, 204));

        botaoCadastrarConsorcio.setFont(new java.awt.Font("Tahoma", 1, 12));
        botaoCadastrarConsorcio.setText("Cadastrar Consórcio");

        botaoGerarGrafico.setFont(new java.awt.Font("Tahoma", 1, 12));
        botaoGerarGrafico.setText("Gerar Gráficos");
        botaoGerarGrafico.setAutoscrolls(true);
        botaoGerarGrafico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoGerarGraficoActionPerformed(evt);
            }
        });

        jScrollPane1.setViewportView(jTable2);

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("Lista de Clientes Cadastrados em Consórcios");

        jPanel5.setBackground(new java.awt.Color(204, 204, 204));
        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        radioPlano.setBackground(new java.awt.Color(204, 204, 204));
        buttonGroupPesquisa.add(radioPlano);
        radioPlano.setSelected(true);
        radioPlano.setText("Plano");

        radioModelo.setBackground(new java.awt.Color(204, 204, 204));
        buttonGroupPesquisa.add(radioModelo);
        radioModelo.setText("Modelo");

        radioData.setBackground(new java.awt.Color(204, 204, 204));
        buttonGroupPesquisa.add(radioData);
        radioData.setText("Data");

        campoPesquisa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoPesquisaActionPerformed(evt);
            }
        });

        botaoPesquisa.setFont(new java.awt.Font("Tahoma", 1, 12));
        botaoPesquisa.setText("Pesquisar");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setText("Pesquisa");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(botaoPesquisa)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel2)
                        .addComponent(campoPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(91, 91, 91)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(radioModelo)
                    .addComponent(radioPlano)
                    .addComponent(radioData))
                .addGap(83, 83, 83))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(radioPlano)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(radioModelo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(radioData))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(campoPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botaoPesquisa)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        botaoExcluirConsorcio.setFont(new java.awt.Font("Tahoma", 1, 12));
        botaoExcluirConsorcio.setText("Atualizar");

        botaoSair.setFont(new java.awt.Font("Tahoma", 1, 12));
        botaoSair.setText("Sair");

        botaoRelatorio.setFont(new java.awt.Font("Tahoma", 1, 12));
        botaoRelatorio.setText("Imprimir Relação");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 477, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(botaoSair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(botaoRelatorio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(botaoExcluirConsorcio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(botaoCadastrarConsorcio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(botaoGerarGrafico, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(botaoGerarGrafico, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botaoCadastrarConsorcio, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botaoExcluirConsorcio, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botaoRelatorio, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botaoSair, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(83, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void campoPesquisaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoPesquisaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoPesquisaActionPerformed

    private void botaoGerarGraficoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoGerarGraficoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_botaoGerarGraficoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoCadastrarConsorcio;
    private javax.swing.JButton botaoExcluirConsorcio;
    private javax.swing.JButton botaoGerarGrafico;
    private javax.swing.JButton botaoPesquisa;
    private javax.swing.JButton botaoRelatorio;
    private javax.swing.JButton botaoSair;
    private javax.swing.ButtonGroup buttonGroupPesquisa;
    private javax.swing.JTextField campoPesquisa;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable2;
    private javax.swing.JRadioButton radioData;
    private javax.swing.JRadioButton radioModelo;
    private javax.swing.JRadioButton radioPlano;
    // End of variables declaration//GEN-END:variables


    public String getBotaoExcluir() {
        return botaoExcluirConsorcio.getName();

    }
}
